<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="projectBase__PUBLIC__/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="projectBase__PUBLIC__/js/lhgdialog.js"></script>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<style type="text/css">
body{margin:0;padding:0;}
	</style>
	<style>
#addMenu-form div { padding:5px;  }
#addMenu-form input { width:15em; padding:4px; border:1px solid #CCC; }
#addMenu-form input:focus { border-color:#426DC9; }
#addMenu-form .login-form-error { background:#FFFBFC; border-color:#F00 !important; }
</style>
<script type="text/javascript">

function addMenu(){
	
	menuName=$('#MENU_NAME').val();
	
	menuOrder=$('#MENU_ORDER').val();
	
	$.ajax({
		  url: '__APP__/AddMenu/addLevelTwo',
		  dateType: "json",
		  data:{MENU_NAME:menuName,MENU_ORDER:menuOrder,parentID:$('#parentID').val()},
		  success: function(data) {
			 var re= eval("(" + data + ")");
		  if(re.status=='1'){
			  var api = frameElement.api;
				//api.parent().location.reload(true);
				api.opener.location.reload();
				api.close();
		  }
		  }
		});
}

$(document).ready(function(){
	
	$('#cancel').click(function(){
		var api = frameElement.api;
		api.close();
	});
	
	$('#confirm').click(function(){
		addMenu();
	});
	
})
</script>
</head>

<body>

<form action="" id="addMenu-form">
<div>
<input  type="hidden" value="{$parentID}" id="parentID"/>
<label for="menuName">菜单名称</label>
 <input type="text" name="MENU_NAME" id="MENU_NAME"/><BR>
 <label for="MenuOrder" style="margin-top:4px">显示顺序</label>
 <input type="text" name="MENU_ORDER" id="MENU_ORDER" value="0" /><BR>
 <input type="button"  id="cancel" value="取消" style="width:40px;height:25px;float:right;margin-top:5px;margin-right:3px"/>
 <input type="button" id="confirm" value="确定" style="width:40px;height:25px;float:right;margin-top:5px;margin-right:5px"/>
 </div>
 <script type="text/javascript">
var api = frameElement.api, //返回当前最顶层窗口实例对象
	$$ = function(id){return document.getElementById(id)},
	form = $$('addMenu-form'),
	menuName = $$('MENU_NAME'),
	password = $$('MENU_ORDER');

	api.button()
// 操作对话框
api.title('添加一级菜单')
	// 自定义按钮
	// 锁屏
	.lock();
	
menuName.focus();

// 表单验证
var check = function (input) {
	if (input.value === '') {
		inputError(input);
		input.focus();
		return false;
	} else {
		return true;
	};
};

// 输入错误提示
var inputError = function (input) {
	clearTimeout(inputError.timer);
	var num = 0;
	var fn = function () {
		inputError.timer = setTimeout(function () {
			input.className = input.className === '' ? 'login-form-error' : '';
			if (num === 5) {
				input.className === '';
			} else {
				fn(num ++);
			};
		}, 150);
	};
	fn();
};
</script>
</form>
</body>
</html>